package de.jabc.sib.bio.ebi;

import de.jabc.adapter.bio.ebi.Branches;
import de.jabc.adapter.bio.ebi.LightweightServiceAdapter;
import de.jabc.adapter.bio.ebi.ServiceAdapter;
import de.metaframe.jabc.framework.execution.ExecutionEnvironment;
import de.metaframe.jabc.framework.sib.annotation.SIBClass;
import de.metaframe.jabc.framework.sib.annotation.SIBStatus;
import de.metaframe.jabc.framework.sib.parameter.ContextExpression;
import de.metaframe.jabc.framework.sib.parameter.ContextKey;
import de.metaframe.jabc.sib.ServiceAdapterDescriptor;

/**
 * Calls the EBI's NCBI BLAST service.
 * 
 * @author anna-lena
 * @version $Revision: 3325 $ $Date: 2008-03-03 13:34:38 +0100 (Mon, 03 Mar
 *          2008) $
 */
@SIBClass("ebi-sibs/PsiSearch")
@SIBStatus("IMPLEMENTED")
public class PsiSearch extends AbstractSIB {

	/* Branches */
	public static final String[] BRANCHES = { Branches.DEFAULT, Branches.ERROR };

	/* Parameters */
	public ContextExpression Email = new ContextExpression("", String.class,
			false);
	public ContextExpression Title = new ContextExpression("", String.class,
			false);
	public ContextExpression Matrix = new ContextExpression("", String.class,
			false);
	public ContextExpression Gapopen = new ContextExpression("", String.class,
			false);
	public ContextExpression Gapext = new ContextExpression("",
			String.class, false);
	public ContextExpression Expthr = new ContextExpression("", String.class,
			false);
	public ContextExpression Mask = new ContextExpression("", String.class,
			false);
	public ContextExpression Psithr = new ContextExpression("", String.class,
			false);
	public ContextExpression Scores = new ContextExpression("",
			String.class, false);
	public ContextExpression Alignments = new ContextExpression("", String.class,
			false);
	public ContextExpression Scoreformat = new ContextExpression("", String.class,
			false);
	public ContextExpression Sequence = new ContextExpression("", String.class,
			false);
	public ContextExpression Database = new ContextExpression("", String.class,
			false);
	public ContextExpression Previousjobid = new ContextExpression("", String.class,
			false);
	public ContextExpression SelectedHits = new ContextExpression("", String.class,
			false);
	public ContextExpression Cpfile = new ContextExpression("", String.class,
			false);
	public ContextKey resultJobid = new ContextKey("result_jobid", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultOut = new ContextKey("result_out", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultSequence = new ContextKey("result_sequence", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultIds = new ContextKey("result_ids", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultPreselectedIds = new ContextKey("result_preselected_ids", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultXml = new ContextKey("result_xml", ContextKey.Scope.LOCAL,
			true);

	
	/**
	 * @see de.metaframe.jabc.sib.CodeGeneratorBlock#execute(ExecutionEnvironment)
	 */
	public String execute(ExecutionEnvironment environment) {
		try {
			return ServiceAdapter.callPsiSearch(environment, this.Email,
					this.Title, this.Matrix, this.Gapopen, this.Gapext,
					this.Expthr, this.Mask, this.Psithr, this.Scores,
					this.Alignments, this.Scoreformat, this.Sequence, this.Database,
					this.Previousjobid, this.SelectedHits, this.Cpfile, this.resultJobid, this.resultOut,
					this.resultSequence, this.resultIds, this.resultPreselectedIds, this.resultXml);
		} catch (NoClassDefFoundError e) {
			return Branches.ERROR;
		}
	}

	/**
	 * @see de.metaframe.jabc.sib.Generatable#generate()
	 */
	public ServiceAdapterDescriptor generate() {
		return new ServiceAdapterDescriptor(LightweightServiceAdapter.class
				.getName(), "callPsiSearch", "Email", "Title", "Matrix",
				"Gapopen", "Gapext", "Expthr", "Mask", "Psithr",
				"Scores", "Alignments", "Scoreformat", "Sequence", "Database", "Previousjobid", "SelectedHits", "Cpfile",
				"resultJobid", "resultOut", "resultSequence", "resultIds", "resultPreselectedIds", "resultXml");
	}

}
